/*
 * Copyright (c) 2009, Jan Pastor. All Rights Reserved.
 */

package sk.jp.jitag.dao.db4o.model;

import sk.jp.jitag.dao.db4o.Column;
import sk.jp.jitag.dao.db4o.CascadeOnDelete;
import sk.jp.jitag.dao.db4o.BaseEntity;

public class User extends BaseEntity {

    private static final Column _LOGIN = new Column("login");
    private static final Column _PROFILE = new Column("profile");

    private String login;
    private String password = null;

    @CascadeOnDelete
    private UserProfile profile;

    //----------------------------------------------------------------------

    public User(String login, UserProfile profile) {
        checkNotNullNotEmpty(_LOGIN, login);
        checkNotNull(_PROFILE, profile);

        this.login = login;
        this.profile = profile;
    }

    public String getLogin() {
        return login;
    }

    public String getPassword() {
        return password;
    }

    public User setPassword(String password) {
        this.password = password;
        return this;
    }

    public UserProfile getProfile() {
        return profile;
    }

    @Override
    public String toString() {
        final StringBuilder sb = new StringBuilder();
        sb.append("User");
        sb.append("{login='").append(login).append('\'');
        sb.append(", password='").append(password).append('\'');
        sb.append(", profile=").append(profile);
        sb.append('}');
        return sb.toString();
    }
}
